package com.dq.Week3.day13.homework;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class FootBallDemo {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        HashMap<String, String> map = new HashMap<>();
        map.put("2038","拆纳");
        map.put("2034","拆纳");
        map.put("2030","拆纳");
        map.put("2026","拆纳");
        map.put("2006", "意大利");
        map.put("2002", "巴西");
        map.put("1998", "法国");
        map.put("1994", "巴西");
        map.put("1990", "德国");
        map.put("1986", "阿根廷");
        map.put("1982", "意大利");
        map.put("1978", "阿根廷");
        map.put("1974", "德国");
        map.put("1970", "巴西");
        map.put("1966", "英格兰");
        map.put("1962", "巴西");
        map.put("1958", "巴西");
        map.put("1954", "德国");
        map.put("1950", "乌拉圭");
        map.put("1938", "意大利");
        map.put("1934", "意大利");
        map.put("1930", "乌拉圭");


        while (true)
        {
            System.out.println("请输入你要进行的操作: 1.通过年份查冠军 2.通过队伍查冠军年份 3.退出");
            int i = scanner.nextInt();
            switch (i)
            {
                case 1:
                    System.out.println("请输入年份");
                    String year = scanner.next();
                    if(map.containsKey(year)==false)
                    {
                        System.out.println("您输入的年份没举办过世界杯~_~");
                    }else{
                        System.out.println(year+"年的冠军是："+map.get(year));
                    }
                    break;
                case 2:
                    System.out.println("请输入队伍");
                    String footTeam = scanner.next();
                    if(map.containsValue(footTeam)==false)
                    {
                        System.out.println(footTeam+"队还没有得过冠军哦^3^");
                    }else {

                        System.out.println(footTeam+"队的夺冠年份是：");
                    }
                        for (String s : map.keySet()) {
                            if(map.get(s).equals(footTeam))
                            {
                                System.out.println(" "+s);

                            }
                    }
                    break;
                case 3:
                    return;
                default:
                    System.out.println("输入格式错误");

            }
        }
    }

}
